//
//  UIImage+Color.swift
//  YFBAgentV3
//
//  Created by admin on 2025/9/5.
//

import UIKit

public extension UIView {
    
    /// 加载XIB返回视图
    class func viewFromNib(nibName: String) -> Any? {
        
        let nibArray = Bundle.main.loadNibNamed(nibName, owner: self, options: nil)
        if (nibArray == nil || nibArray!.count <= 0) {
            return nil;
        }
        if (nibArray!.first is UIView) {
            (nibArray!.first as! UIView).restorationIdentifier = nibName
        }
        return nibArray!.first;
    }
    
    
    /// 设置圆角
    func setupCornerRadius(direction: UIRectCorner, radii: Double, frame: CGRect? = nil) {
        let maskPath = UIBezierPath(roundedRect: (frame != nil ? frame! : self.bounds),
                                    byRoundingCorners: direction, cornerRadii: CGSize(width: radii, height: radii))
        let maskLayer = CAShapeLayer()
        maskLayer.frame = (frame != nil ? frame! : self.bounds)
        maskLayer.path = maskPath.cgPath
        self.layer.mask = maskLayer
    }
    
 

}
